package com.wm.wmim.connect.ws.config;

import com.wm.wmim.connect.ws.controller.WsHandler;
import com.wm.wmim.connect.ws.interceptor.WsHandshakeInterceptor;
import org.springframework.stereotype.Component;
import org.springframework.web.socket.config.annotation.*;

import javax.annotation.Resource;

@Component
@EnableWebSocket
public class WebSocketConfig implements WebSocketConfigurer{

    @Resource
    private WsHandler wsHandler;

    @Resource
    private WsHandshakeInterceptor wsHandshakeInterceptor;

    @Override
    public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
        registry.addHandler(wsHandler, "/chat")
                .setAllowedOrigins("*")
                .addInterceptors(wsHandshakeInterceptor);
        ;
    }


}